package com.zjw;

import com.zjw.entity.Subject;
import com.zjw.service.StudentService;
import com.zjw.service.SubjectService;
import com.zjw.service.impl.StudentServiceImpl;
import com.zjw.service.impl.SubjectServiceImpl;

import java.util.List;
import java.util.Scanner;

/**
 * @projectName: studentCourseSelectionManagement
 * @package: com.zjw
 * @className: Test2
 * @author: 翟
 * @date: 2025/4/7 0:56
 */

public class Test2 {
    /**
     * 查询指定学号学生的课程信息(课程编号、课程名称、课时）
     */
    public static void main(String[] args) {
        StudentService studentService = new StudentServiceImpl();
        SubjectService subjectService = new SubjectServiceImpl();
        do {
            System.out.println("请输入学号:");
            int studentId = new Scanner(System.in).nextInt();
            if (studentService.isExistStudentId(studentId)){
                List<Subject> list = subjectService.getSubjectListByGradeId(studentService.getGradeIdByStudentNo(studentId));
                for (Subject subject : list) {
                    System.out.println("课程编号:" + subject.getSubjectNo() + "\t\t课程名称:" + subject.getSubjectName() + "\t\t课时:" + subject.getClassHour());
                }
            }else {
                System.out.println("学号不存在");
            }
        }while (true);


    }
}
